package com.example.activities;

import com.example.demo.R;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.os.Build;

public class HttpPostREQPage extends ActionBarActivity {
	EditText edtNickname, edtPassword;
	TextView txtResult;
	Button btnSubmit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_http_post_reqpage);

		edtNickname = (EditText) findViewById(R.id.edtAsyncNickname);
		edtPassword = (EditText) findViewById(R.id.edtAsyncPassword);
		txtResult = (TextView) findViewById(R.id.txtResult);
		btnSubmit = (Button) findViewById(R.id.btnSubmitData);
		btnSubmit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (checkData(edtNickname.getText().toString(), edtPassword
						.getText().toString()) == true) {
					txtResult
							.setText("Please enter both of nickname and password!");
					txtResult.setTextColor(Color.BLUE);
				}
			}
		});

	}

	private boolean checkData(String nickname, String password) {
		if (nickname.toString().trim().length() < 1
				|| password.toString().trim().length() < 1) {
			txtResult.setText("Please enter both of nickname and password!");
			txtResult.setTextColor(Color.RED);
			return false;
		}
		return true;
	}
}
